﻿using System;
using System.Linq;

public partial class GetPwd : System.Web.UI.Page
{
    MyDataDataContext db = new MyDataDataContext();
    protected void Page_Load(object sender, EventArgs e)
    {
        
    }
    protected void BtnResetPwd_Click(object sender, EventArgs e)
    {
        User user= (from c in db.User
                    where c.UserNickname == txtName.Text
                    select c).First();
        if(user != null)
        {
            if (txtNum.Text == Button1.Text)
            {
                user.UserPwd = txtPwd.Text;
                db.SubmitChanges();
                lblMsg.Text = "密码重置成功！";
            }
            
        }
        
    }
   
    //获取验证码并显示
    protected void Button1_Click(object sender, EventArgs e)
    {
        Random rm = new Random();
        string s = Convert.ToString(rm.Next(1000, 9999));
        Button1.Text = s;
        
    }
}